Skip to content

Support smoothing onto lat-lon and projection grids - #217

Merged
xylar merged 2 commits into
MPAS-Dev:mainfrom
xylar:fix-expand-structured-dst
Dec 2, 2026
Merged

xylar merged 2 commits into
MPAS-Dev:mainfrom
xylar:fix-expand-structured-dst

Conversation

@xylar

@xylar xylar commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Smoothing with expand_dist or expand_factor now works for lat-lon and projection destinations, which ESMF rejected before. The expanded grid is given to the mapping tool as unstructured, and a new public Remapper.finalize_map() then puts the true destination shape, corners and cell areas back in the mapping file, so only the weights carry the smoothing.

  • build_map() calls finalize_map() itself. Callers that run the command from prepare_map(), such as Polaris's MappingFileStep, need to call it afterwards.
  • Expanded maps to MPAS meshes now also record the true corners and cell areas instead of the expanded ones. Their weights are unchanged, but ncremap() output gets correct bounds and areas.

Fixes #210

Checklist

  • Documentation has been updated
  • API documentation (docs/developer_guide/api.md) has any new or modified class, method and/or functions listed
  • Documentation has been built locally and changes look as expected
  • Testing comment in the PR documents testing used to verify the changes
  • New tests have been added to tests/

Posted by Claude Code on @xylar's behalf

xylar and others added 2 commits December 2, 2026 10:34
ESMF_RegridWeightGen reads a SCRIP grid of rank 2 as logically
rectangular, with neighboring cells sharing corners.  Expanding the
destination cells (expand_dist or expand_factor) moves each cell's
corners independently, so ESMF could not arrange them and failed for
lat-lon and projection destinations.

expand_scrip() now writes an expanded grid of rank 2 as unstructured,
which ESMF accepts.  The mapping file then describes the destination
as 1D, with the expanded corners and cell areas.  A new
Remapper.finalize_map() rewrites it with the shape, corners and (for
conservative maps) cell areas of the true destination grid, so only
the weights reflect the expansion and remap_numpy() and ncremap() give
output on the destination grid.  Cell areas are computed for corners
joined by great circles, as ESMF computes them.  This applies to every
expanded destination, so expanded maps to MPAS meshes now also carry
the true corners and areas rather than the expanded ones; their
weights are unchanged.

build_map() calls finalize_map() itself.  Callers that run the command
from prepare_map() must call it afterwards.  Without expansion it does
nothing.

Fixes MPAS-Dev#210

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xylar

xylar commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator Author

Posted by Claude Code on @xylar's behalf

Testing

The new tests in tests/test_remapper_expand.py build conservative maps from a 2° lat-lon grid with expand_dist=100e3 onto a 10° lat-lon grid, an Antarctic polar grid and the oQU240 mesh. Each expanded map has the same destination shape, corners and cell areas (to 1e-6) as the map without expansion, and more weights. remap_numpy() maps a constant to 1, and ncremap() writes the same lat, lon, bounds and area as without expansion. prepare_map() followed by finalize_map() gives the same file as build_map(). All five tests fail on main. The full suite passes (82 tests), and the docs build with -W. MOAB was not run.

@xylar xylar added bug Something isn't working enhancement New feature or request labels Dec 2, 2026
@xylar
xylar merged commit 46d680f into MPAS-Dev:main Dec 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smoothing onto lat-lon or projection grids fails in ESMF

1 participant